package com.wangx1n;


import com.wangx1n.bean.Person;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author WangXin
 * @date 2020/12/3 14:04
 */
public class MyTest {
//    bean生命周期
    @Test
    public void BeanLifeCycleTest(){
        ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
        Person person = context.getBean("person", Person.class);
        if (person!=null){
            System.out.println("4.得到了bean对象");
            System.out.println(person);
        }
//       ApplicationContext中没有close方法，必须要子接口或者其子接口实现类才有close方法
        ((AbstractApplicationContext) context).close();
    }
}
